package com.hikvision.rpq.sblearn.controller;

import com.hikvision.rpq.sblearn.annoition.Metrics;
import com.hikvision.rpq.sblearn.common.BusinessErrorCode;
import com.hikvision.rpq.sblearn.common.ResponseInfo;
import com.hikvision.rpq.sblearn.entity.User;
import com.hikvision.rpq.sblearn.entity.expertWarning.ExpertWarning;
import com.hikvision.rpq.sblearn.exception.BusinessException;
import com.hikvision.rpq.sblearn.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * @author renpeiqian
 * @date 2021/9/7 14:59
 * @since
 */
@RestController
@RequestMapping("/test")
public class TestController {

    @Autowired
    UserService userService;

    @Autowired
    User user;

    @GetMapping("/get")
    public User test(@RequestBody User user){
        System.out.println(user);
        user.setUsername("hikvision");
        user.setPassword("password");
        return user;
    }




    @PostMapping("/save")
    public ResponseInfo testException(@RequestBody ExpertWarning expertWarning){
        LocalDateTime date = LocalDateTime.parse(expertWarning.getDateTime(), DateTimeFormatter.ISO_OFFSET_DATE_TIME);
        System.out.println(date);
        System.out.println(expertWarning);
        ResponseInfo<User> responseInfo = new ResponseInfo<>();
        userService.saveUser(user);
        return responseInfo;
    }



}
